package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.bean.MouseBean;
import com.project.dao.MouseDao;
import com.project.service.MouseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 鼠害
 */

@Service
@Transactional
public class MouseServiceImpl extends ServiceImpl<MouseDao, MouseBean> implements MouseService {
    @Override
    public IPage<MouseBean> findAllMouse(int pageNo, int pageSize) {
        Page<MouseBean> page = new Page<>(pageNo,pageSize);
        IPage<MouseBean> iPage = this.page(page);
        return iPage;
    }

    @Override
    public void addMouse(MouseBean mouse) {
        this.baseMapper.addMouse(mouse);

    }

    @Override
    public MouseBean findId(int mouseId) {
        return this.baseMapper.findId(mouseId);
    }

    @Override
    public IPage<MouseBean> findName(int pageNo, int pageSize, String mouseName) {
        Page<MouseBean> page = new Page<>(pageNo,pageSize);
        QueryWrapper wrapper = new QueryWrapper();
        if (mouseName!=null && !mouseName.equals("")){
            wrapper.like("f_mouseName",mouseName);
        }
        IPage<MouseBean> iPage = this.page(page,wrapper);
        return iPage;
    }
}
